#include<stdio.h>
main() {
	double x, sum;

	scanf_s("%lf", &x);
	sum = ((((3 * x + 2) * x - 5) * x - 1) * x + 7) * x - 6;
	printf("%g", sum);
	return 0;
}